package testview.zhen.com.myapplication

import android.util.Log

import org.junit.Test

import javax.security.auth.login.LoginException

import org.junit.Assert.*
import testview.zhen.com.myapplication.hencoder.Animal
import testview.zhen.com.myapplication.hencoder.Cat
import testview.zhen.com.myapplication.hencoder.Example1

/**
 * Create by ldr
 * on 2019/9/2 16:17.
 */
class MainActivityTest {
    @Test
    fun toNotify() {
        val builder = StringBuilder("原来的builder")

        //       StringBuilder builder1 = new StringBuilder("原来的builder");
        var builder2 = builder
        val builder3 = builder2
        val builder4 = StringBuilder()
        builder2 = builder4

        Log.i(TAG, "build == builder2" + (builder == builder2))
        Log.i(TAG, "builder3 == builder" + (builder == builder3))
        Log.i(TAG, "builder4 == builder" + (builder == builder4))
        Log.i(TAG, "builder3 == builder1" + (builder == builder3))


        val isequ = builder.toString() == builder.toString()
        val isde = builder == builder
        Log.i(TAG, "toNotify: isequ:$isequ  isde:$isde")

        val `is` = builder == builder2
        Log.i(TAG, " builder2 == builder :$`is`")
        builder2.append("这个是附加上去的信息")
        Log.i(TAG, "builder:$builder")
        Log.i(TAG, "builder2:$builder")
        Log.i(TAG, "builder2 == builder:" + (builder == builder2))
        Log.i(TAG, "builder: $builder")
        Log.i(TAG, "builder2: $builder2")
        Log.i(TAG, "builder: $builder")

    }

    @Test
    fun testFillExample1() {
        var exam: Example1 = Example1()
        var a: Array<in Cat> = Array(1) { Animal() }
        System.out.println((a[0] as Animal).print())
        exam.fill(a, Cat())
    }

    @Test
    fun testCopy() {
        var exam = Example1()
        var a: Array<Cat> = arrayOf(Cat("cat原1"),Cat("cat原2"),Cat("cat原3"),Cat("cat原4"),Cat("cat原5"))
        var a1: Array<Cat> = arrayOf(Cat("cat1"),Cat("cat2"),Cat("cat3"),Cat("cat4"),Cat("cat5"))
        exam.copy(a, a1)
    }

    companion object {

        private val TAG = "MainActivityTest"
    }


}